]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
smartcardManager: Properly disconnect signal connections from tokens
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 24 Jul 2025 23:30:29 +0000 (01:30 +0200)
committerJonas Dreßler <verdre@v0yd.nl>
Wed, 30 Jul 2025 20:40:57 +0000 (22:40 +0200)
The `token.disconnectAll()` call here is not going to work: The method is
provided by gjs as convenience for native JS objects (added to an object
using `Signals.addSignalMethods()`). The token here meanwhile is a GObject,
which doesn't have a `disconnectAll()` method.

To make it (hopefully) work as intended, use the convenience functions
that we actually do add to GObjects, that is `connectObject()` and
`disconnectObject()`.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3796>

js/misc/smartcardManager.js

index f5a438c89778bfaf6fa78869a72dfc414a6ab71e..b886110d915fa969a83c99f9f245e9357910c66f 100644 (file)
@@ -72,7 +72,7 @@ class SmartcardManager extends Signals.EventEmitter {
     _addToken(token) {
         this._updateToken(token);
 
-        token.connect('g-properties-changed', (proxy, properties) => {
+        token.connectObject('g-properties-changed', (proxy, properties) => {
             const isInsertedChanged = !!properties.lookup_value('IsInserted', null);
             if (isInsertedChanged) {
                 this._updateToken(token);
@@ -82,7 +82,7 @@ class SmartcardManager extends Signals.EventEmitter {
                 else
                     this.emit('smartcard-removed', token);
             }
-        });
+        }, this);
 
         // Emit a smartcard-inserted at startup if it's already plugged in
         if (token.IsInserted)
@@ -100,7 +100,7 @@ class SmartcardManager extends Signals.EventEmitter {
         if (this._loginToken === token)
             this._loginToken = null;
 
-        token.disconnectAll();
+        token.disconnectObject(this);
     }
 
     hasInsertedTokens() {